package com.noocodecommit.wicket.jquery.plugin.enchant.shake;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;

import com.noocodecommit.wicket.jquery.TemplatePage;
import com.noocodecommit.wicket.stuff.jquery.JQCore;
import com.noocodecommit.wicket.stuff.jquery.plugin.chili.JQChili;
import com.noocodecommit.wicket.stuff.jquery.plugin.effects.JQAnimationUtils;
import com.noocodecommit.wicket.stuff.jquery.plugin.effects.shake.JQShake;
import com.noocodecommit.wicket.stuff.jquery.plugin.effects.shake.JQShakeOptions;
import com.noocodecommit.wicket.stuff.jquery.plugin.effects.shake.JQShakePlugin;

public class ShakePage extends TemplatePage
{
	public ShakePage()
	{
		super();
		this.setupChili();

		// -- Init effect plugin
		JQCore.get().bindPlugin(new JQShakePlugin());

		final Label block = new Label("block", "block");
		block.setOutputMarkupId(true);
		add(block);

		add(new AjaxLink("effect1")
		{
			public void onClick(AjaxRequestTarget target)
			{
				JQAnimationUtils.create(block).animation(new JQShake(3)).effect(target);
			}
		});
		add(new AjaxLink("effect2")
		{
			public void onClick(AjaxRequestTarget target)
			{
				JQAnimationUtils.create(block).animation(new JQShake(60, JQShakeOptions.DIRECTION_LEFT, 5, JQShakeOptions.SPEED_DEFAULT)).effect(target);
			}
		});
		add(new AjaxLink("effect3")
		{
			public void onClick(AjaxRequestTarget target)
			{
				JQAnimationUtils.create(block).animation(new JQShake(JQShakeOptions.DIRECTION_UP)).effect(target);
			}
		});
		JQChili chili1 = new JQChili("chili1");
		add(chili1);
		this.bindChiliCode(chili1, this.getClass(), "html");

		JQChili chili2 = new JQChili("chili2");
		add(chili2);
		this.bindChiliCode(chili2, this.getClass(), "java");
		JQCore.get().bindOnDocumentReadyFunction();
	}
}
